<template>
  <div>
    <van-card
      v-for="item in newList"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      @click="datail(item.id)"
    >
      <div slot="tags">
        <span>发布时间：{{item.add_time.split('T')[0]}}</span>
        <span class="f2">点击:{{item.click}}</span>
      </div>
    </van-card>
  </div>
</template>

<script>
import { async } from 'q'
export default {
  data() {
    return {
      newList: []
    }
  },
  created() {
    this.getNewList()
  },
  methods: {
    async getNewList() {
      const { data: res } = await this.$http.get('/api/getnewslist')
      if (res.status !== 0) {
        return this.$toast.fail('获取商品数列表失败！')
      }
      this.newList = res.message
    },
    datail(id) {
      this.$router.push(`/news/detail/${id}`)
    }
  }
}
</script>

<style lang="less" scoped>
.van-card {
  background: #fff;
  border-bottom: 1px solid #eee;
  margin: 0 10px;
  padding: 10px;
  .van-card__thumb {
    width: 42px;
    height: 42px;
    .van-image__img {
      width: 100%;
      height: 100%;
    }
  }
  .van-card__content {
    min-height: 0;
    .van-card__title {
      height: 17px;
      font-size: 14px;
      font-weight: 700;
      color: #000;
    }
    span {
      height: 30px;
      line-height: 30px;
      color: #226aff;
      letter-spacing: 0.2em;
    }
    .f2 {
      float: right;
    }
  }
}
</style>
